<template>
  <div class="my-projectPayment basic-from">
    <v-dialog title="查看" :show.sync="dialogVisible" width="1200px" @beforeClose="beforeClose" :close-on-click-modal="false">
      <div class="card-box p0">
        <div class="card-title">合同信息</div>
        <el-form ref="projectContract" :model="projectForm.projectContract" class="form-wrap" size="small" label-position="top">
          <el-form-item label="合同编号" prop="contractNum">
            <span class="int-text">{{projectForm.projectContract.contractNum}}</span>
          </el-form-item>
          <el-form-item label="合同类型" prop="contractType">
            <span class="int-text">{{getCardTypeValue(projectForm.projectContract.contractType,contractTypes)}}</span>
          </el-form-item>
          <el-form-item label="合同总金额(元)" prop="contractAmount">
            <span class="int-text">{{projectForm.projectContract.contractAmount | thousandMoney}}</span>
          </el-form-item>
          <el-form-item label="签订日期" prop="contractDate">
            <span class="int-text">{{projectForm.projectContract.contractDate}}</span>
          </el-form-item>
          <el-form-item label="乙方单位名称" prop="partybUnit">
            <span class="int-text">{{projectForm.projectContract.partybUnit}}</span>
          </el-form-item>
        </el-form>
        <div class="card-title">本次付款信息</div>
        <el-form ref="projectPayment" :model="projectForm.projectPayment" class="form-wrap" size="small" label-position="top">
          <el-form-item label="第几次" prop="payNum">
            <span class="int-text">{{projectForm.projectPayment.payNum}}次</span>
          </el-form-item>
          <el-form-item label="付款支付日期" prop="payDate">
            <span class="int-text">{{projectForm.projectPayment.payDate}}</span>
          </el-form-item>
          <el-form-item label="支付金额(元)" prop="payAmount">
            <span class="int-text">{{projectForm.projectPayment.payAmount | thousandMoney}}</span>
          </el-form-item>
          <el-form-item label="意见" class="full" prop="remarks">
            <span class="int-text">{{projectForm.projectPayment.remarks}}</span>
          </el-form-item>
        </el-form>
        <div class="card-title">附件</div>
        <div class="handling-opinions">
          <v-upload
            ref="paymentUpload"
            :busId="projectForm.projectPayment.projectPaymentId"
            modelType="projectPayment"
            isShowFileList
            :isView="true"
            multiple
            v-model="fileList"
          />
        </div>
      </div>
      <span slot="foot">
        <el-button @click="$bus.$emit('operationLog', projectForm.projectContract.projectId)">操作日志</el-button>
        <el-button type="primary" @click="handleCancel">关 闭</el-button>
      </span>
    </v-dialog>
  </div>
</template>

<script>
import { get } from "../api/payment";

export default {
  name: "show-actual",
  created () {
    this.contractTypes = this.getDict("epc_contract_type")
  },
  data () {
    return {
      dialogVisible: false,
      projectForm: {
        projectContract: {
          projectContractId: '',
          projectId: '',
          projectPaymentId: '',
          contractNum: '',
          contractType: '',
          contractAmount: '',
          contractDate: '',
          partybUnit: ''
        },
        projectPayment: {
          payNum: '',
          payDate: '',
          payAmount: '',
          remarks: '',
          projectContractId: '',
          projectId: '',
          projectPaymentId: '',
        }
      },
      contractTypes: [],
      fileList: [],
    }
  },
  methods: {
    //打开弹框
    show (item) {
      this.dialogVisible = true
      if (item) {
        this.projectForm.projectPayment.projectPaymentId = item
        get(item).then(res => {
          if (res.data.code === 0) {
            this.projectForm.projectContract = res.data.data.projectContract
            this.projectForm.projectPayment = res.data.data.projectPayment
          } else {
            this.$message.warning('暂未获取到数据！')
          }
        })
      }
    },
    //关闭弹框
    beforeClose (done) {
      this.$emit('beforeClose')
    },
    //取消
    handleCancel () {
      this.$emit('handleClose')
      this.dialogVisible = false
    },
    //对应value取label
    getCardTypeValue (num, sum) {
      let arr = sum.filter(e => e.value === num)
      if (arr.length > 0) {
        return arr[0].label
      } else {
        return num
      }
    },
  }
}
</script>

<style scoped lang='scss'>
.handling-opinions {
  padding: 20px;
}
.int-text {
  color: #999;
}
</style>
